/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.pizzaria.view;

import br.com.pizzaria.util.Global;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JInternalFrame;
import javax.swing.Timer;

/**
 *
 * @author Jaime
 */
public class MenuContasPagar extends javax.swing.JInternalFrame {

    /**
     * Creates new form MenuProdução
     */
    public MenuContasPagar() {
        initComponents();
        Timer time = new Timer(1000,ativar);
        time.start(); 
        
//        btnProduto.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.CTRL_DOWN_MASK), "evento");
//        btnProduto.getActionMap().put("evento", new AbstractAction() {
//
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                btnProdutoActionPerformed(e);
//            }
//
//        });
//        btnTipoProduto.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_2, InputEvent.CTRL_DOWN_MASK), "evento");
//        btnTipoProduto.getActionMap().put("evento", new AbstractAction() {
//
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                btnTipoProdutoActionPerformed(e);
//            }
//
//        });
//        btnPrecoProduto.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_3, InputEvent.CTRL_DOWN_MASK), "evento");
//        btnPrecoProduto.getActionMap().put("evento", new AbstractAction() {
//
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                btnPrecoProdutoActionPerformed(e);
//            }
//
//        });
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setTitle("Menu Contas Pagar");
        setPreferredSize(new java.awt.Dimension(308, 263));
        setVerifyInputWhenFocusTarget(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 292, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 233, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    ActionListener ativar = (  
        new ActionListener(){  
            public void actionPerformed(ActionEvent e){  
                centralizarComponente();
            }  
          
        }  
    );
    
    public final void centralizarComponente() {  
       int x = Global.principal.getLocation().x;
       int y = Global.principal.getLocation().y;
        
        Dimension ds = Global.principal.getSize();
        Dimension dw = getSize();  
        setLocation((0), (0));  
    }
    
    private void centralizaForm(JInternalFrame frame) {
        Dimension desktopSize = Global.principal.Desktop.getSize();
        Dimension jInternalFrameSize = frame.getSize();
        frame.setLocation((desktopSize.width - jInternalFrameSize.width) / 2,
                (desktopSize.height - jInternalFrameSize.height) / 2);
    }
}
